package com.beiding.jsonanalyzer.analyze.query;

import com.beiding.jsonanalyzer.analyze.func.FuncBase;

/**
 * 值比较条件
 *
 * @author 丁常磊
 * @date 2022/6/10 14:06
 */

public class ValueCondition extends SimpleCondition {


    private Comparator comparator;

    private FuncBase field;
    private FuncBase value;

    public ValueCondition(FuncBase field, FuncBase value, Comparator comparator) {
        super(field, value);
        this.field = field;
        this.value = value;
        this.comparator = comparator;
    }

    @Override
    protected ComparatorResult compare(Object[] values) {
        return comparator.compare(values[0], values[1]);
    }

    @Override
    public String toString() {
        return field + " " + comparator + " " + value;
    }
}
